package com.gxa.meiye.admin.platform.controller;


import com.gxa.meiye.admin.platform.pojo.vo.ShopVo;
import com.gxa.meiye.admin.platform.pojo.vo.UpdateShopStatusVo;
import com.gxa.meiye.admin.platform.service.ShopdService;
import com.gxa.meiye.core.common.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Api
@RestController
@RequestMapping("/platform/shop")
public class ShopdController {

    @Autowired
    private ShopdService shopService;

    @ApiOperation("商家列表")
    @GetMapping("/list")
    public Map userList(){
        List<ShopVo> userVos = shopService.selectShopList();
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setData(userVos);
        jsonResult.setMsg("查询成功");
        return jsonResult.getMap();
    }

    @ApiOperation("修改商家状态")
    @PostMapping("/updateStatus")
    public Map updateStatus(@RequestBody UpdateShopStatusVo shopVo){
        shopService.updateStatus(shopVo);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setMsg("修改成功");
        return jsonResult.getMap();
    }

    @ApiOperation("查询商家")
    @PostMapping("/selectShops")
    public Map selectShops(String select){
        List<ShopVo> shopVos = shopService.selectShops(select);
        JsonResult jsonResult = new JsonResult();
        jsonResult.setCode("200");
        jsonResult.setMsg("修改成功");
        jsonResult.setData(shopVos);
        return jsonResult.getMap();
    }
}
